<template>
  <div class="box2">
    <h3>营业动态</h3>
    <div id="box3"></div>
  </div>
</template>

<script>
import { findAll } from "@/apis/zhaobaoyi/zhaobaoyi.js";
import * as echarts from "echarts";
export default {
  data() {
    return {
      all: [],
      aaa: [],
      bbb: [],
    };
  },
  mounted() {
    findAll().then((ok) => {
      console.log(ok.data.data);
      this.all = ok.data.data;
      this.all.forEach((item) => {
        this.aaa.push(item.foodName);
        this.bbb.push(item.foodNum);
      });
      var myChart = echarts.init(document.getElementById("box3"));
      var option = {
        title: {
          text: "菜品库存表",
        },
        xAxis: {
          type: "category",
          data: this.aaa,
          axisLabel: {
            interval: 0,
          },
        },
        tooltip: {},
        yAxis: {
          type: "value",
        },
        series: [
          {
            name: "库存",
            data: this.bbb,
            type: "bar",
          },
        ],
      };
      myChart.setOption(option);
    });
  },
};
</script>

<style scoped>
h3 {
  width: 825px;
  height: 45px;
  background-color: rgb(220, 220, 220);
}
.box2 {
  margin-left: 5px;
  border: solid 1px #000;
}
#box3 {
  height: 312px;
}
</style>